package com.zhongjian.technologycal.mall.fragment;

import android.content.Intent;
import android.os.Build;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.WindowManager;

import com.githang.statusbar.StatusBarCompat;
import com.zhongjian.technologycal.mall.R;
import com.zhongjian.technologycal.mall.activity.healthily.fragment.HealthChoiceFragment;
import com.zhongjian.technologycal.mall.activity.healthily.fragment.HealthNewestFragment;
import com.zhongjian.technologycal.mall.activity.main.activity.SearchDataActivity;
import com.zhongjian.technologycal.mall.activity.main.activity.SimpleCaptureActivity;
import com.zhongjian.technologycal.mall.activity.main.activity.SystemMessageActivity;
import com.zhongjian.technologycal.mall.adapter.CommonViewPagerAdapter;
import com.zhongjian.technologycal.mall.base.BaseUserFragment;
import com.zhongjian.technologycal.mall.utils.AppTools;
import com.zhongjian.technologycal.mall.utils.StatusBarUtil;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by wei on 2017/9/18.
 * 今日众建页面功能实现(健康圈)
 */


public class TodayFragment extends BaseUserFragment {
    @BindView(R.id.health_vp)
    ViewPager health_vp;
    @BindView(R.id.health_tab)
    TabLayout health_tab;
    private static int TAB_MARGIN_DIP =60;
    private String[] titles = {"精选","最新"};
    @Override
    protected void init() {
        StatusBarCompat.setStatusBarColor(getActivity(), getResources().getColor(R.color.border_color), true);
        CommonViewPagerAdapter infoPagerAdapter = new CommonViewPagerAdapter(getChildFragmentManager(),titles);
        HealthChoiceFragment appFragment = HealthChoiceFragment.newInstance(titles[0]);
        HealthNewestFragment appFragment1 = HealthNewestFragment.newInstance(titles[1]);
        infoPagerAdapter.addFragment(appFragment);
        infoPagerAdapter.addFragment(appFragment1);
        health_vp.setAdapter(infoPagerAdapter);
        health_tab.setupWithViewPager(health_vp);
        health_vp.setCurrentItem(0);
        health_vp.setOffscreenPageLimit(2);
        AppTools.setIndicator(getActivity(),health_tab,TAB_MARGIN_DIP,TAB_MARGIN_DIP);

    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_health;
    }
    /**
     * 扫一扫
     */
    @OnClick(R.id.img_qrcode)
    public void appQrCode() {
        Intent intent = new Intent(getActivity(), SimpleCaptureActivity.class);
        startActivityForResult(intent, 1);
    }
    /**
     * 搜索
     */
    @OnClick(R.id.et_search)
    public void onClickSeacher() {
        Intent intent = new Intent(getActivity(), SearchDataActivity.class);
        startActivityForResult(intent, 1);
    }
    /**
     * 跳转系统消息
     */
    @OnClick(R.id.ll_system_message)
    public void appClickOpenSystemMessage(){
        Intent intent = new Intent(getActivity(), SystemMessageActivity.class);
        startActivity(intent);

    }


}
